#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<windows.h>
#define LEN sizeof(struct People)
struct People{
	char name[10];
	char sex[4];
	int num;
	char email[20];
	char addr[30];
	struct People* next;
};
struct People* head=NULL;
struct Peopie* end=NULL;
void add_people(){
	system("cls");
	int count;
	printf("选择要添加联系人个数：\n");
	scanf("%d",&count);
	struct People *p1,*p2;
	p1=p2=(struct People*)malloc(LEN);
	int i=0;
	printf("--------------------------------------\n");
	if(head==NULL){
		head=p1;
	}
	else{
		end->next=p1;
	}
	while(count>0){
		printf("请输入第%d个联系人信息:\n",++i);
		printf("姓名：\n");
		scanf("%s",&p1->name);
		printf("性别：\n");
		scanf("%s",&p1->sex);
		printf("电话号码：\n");
		scanf("%d",&p1->num);
		printf("邮箱:\n");
		scanf("%s",&p1->email);
		printf("家庭地址：\n");
		scanf("%s",&p1->addr);
		count--;
		p2->next=p1;
		p2=p1;
		p1=(struct People*)malloc(LEN);
		system("cls");
	}
	p2->next=NULL;
	end=p2;
	printf("全部添加成功！\n");
	system("pause");
}

void views_people(){
	system("cls");
	struct People *pt;
	if(head!=NULL){
		for(pt=head;pt!=NULL;){
			printf("姓名：%s\n性别：%s\n电话号码:%d\n邮箱：%s\n家庭地址：%s\n",pt->name,pt->sex,pt->num,pt->email,pt->addr);
			pt=pt->next;
			printf("-------------------------------------------------------------\n");
		}
	}
	else{
		printf("该系统中无数据！");
	}
	system("pause");
}

